package mypackage;

import java.util.Scanner;

public class ArrToString {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入数组的长度");

        int len=sc.nextInt();

        int[] arr=getArr(len);

        //换成字符串的格式

        String str=arrToGetString(arr);

        System.out.println(str);
    }
    public static int[] getArr(int len){
        int[] arr=new int[len];
        Scanner sc=new Scanner(System.in);

        for (int i = 0; i < len; i++) {
            System.out.println("请输入第"+(i+1)+"个数字");
            int num=sc.nextInt();
            arr[i]=num;
        }
        return arr;
    }

    public static String arrToGetString(int[] arr){
        String str="[";
        for (int i = 0; i < arr.length; i++) {
            char c=(char)(arr[i]+'0');
            str=str+c;
            if(i!=arr.length-1){
                str=str+", ";
            }
        }
        str=str+"]";
        return str;
    }

}
